package com.spontaneappnew.adapters;

import com.spontaneappnew.fragments.AllPlacesFragment;
import com.spontaneappnew.fragments.FBFriendTabFragment;
import com.spontaneappnew.fragments.PlacesByDateFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

public class PlaceListPagerAdapter extends FragmentPagerAdapter {
	
	private static int NUMBER_OF_TABS = 3;

	public PlaceListPagerAdapter(FragmentManager fm) {
		super(fm);
	}

	@Override
	public Fragment getItem(int i) {
		Fragment fragment;
		switch (i) {
	        case 0:
	            fragment = new AllPlacesFragment();
	            break;
			case 1:
				fragment = new PlacesByDateFragment();
				break;
	        case 2:
	        	fragment = new FBFriendTabFragment();
	        	break;
	        default:
	            fragment = new AllPlacesFragment();
	            break;
		}
		return fragment;
	}

	@Override
	public int getCount() {
		return NUMBER_OF_TABS;
	}
	
	@Override
    public CharSequence getPageTitle(int position) {
        switch (position) {
		case 0:
			return "ALL PLACES";
		case 1:
			return "LAST ADDED";
		case 2:
			return "MY FRIENDS";
		default:
			return "";
		}
    }
	
	// used to invalidate all lists once a change happens (radius changed or a new place was added by the user)
	// makes the noitfyDataSetChanged of the adapter reload everything
	@Override
	public int getItemPosition(Object object) {
	    return POSITION_NONE;
	}
	

}
